<?php

/**
 * easyShop v.01 by Raven.Liu *
 * easy way to turn your website to a shopping-enabled site.
 *
 * email: Raven.Liu@163.com
 * @author liuran
 * @copyright 2007
 */
if (!defined('EASYSHOP_FLAG'))
 define('EASYSHOP_FLAG', true);

if (!defined('EASYSHOP_ADMINFLAG'))
 define('EASYSHOP_ADMINFLAG', true);

ob_start();

include_once("./includes/application_top.php");

// include the	default language files.
loadLanguages("common", DEF_SITE_ADMINLANG);

//  auto check the cycled orders.

include_once("../crons/cron_cycledorder.php");


// decide witch page will loading.
if(!empty($Page)){

	// 载入对应页面的自定义语言。
	$tplName = $Page.".htm";
	loadLanguages($Page, DEF_SITE_ADMINLANG);
	loadModules($Page, DEF_SITE_ADMINMODULES);

	// here check the private.
	if(!isAdminLogined()and ($Page != 'toplogin') ){
		header("Location:?page=toplogin");
		die;
	}

	if(is_array($langs['common']))
		$smarty->assign('lang', $langs['common']);

	// 保持兼容前台的模板。
	if(is_array($langs['common']))
	$smarty->assign('langs', $langs['common']);

	if(!$_GET['is_ajax']){
		$smarty->display($tplName);

		echo "<!-- db time ".$db->queryTime(). " query times".$db->queryCount()." -->";

	}
	else
	{
		$return = $_SESSION['ajax'];
		$return['content'] = $smarty->fetch($tplName);
		$json = new Services_JSON();
		echo $json->encode($return);
		die;

	}

}

ob_end_flush();

?>